# $Id: Filter.pm,v 1.4 2004/06/20 08:22:24 ibo Exp $

package CGI::FOGE2::FilterGenerator;
use strict;
use CGI::FOGE2::Form;
use CGI::FOGE2::Tools;

our @ISA = ();

sub new {
    my $proto = shift;
    my $class = ref($proto) || $proto;
    my %args = @_;

    my $self = {
	name => 'filter',
        form => $args{form},
	temp_table => undef,
    };

    bless $self, $class;
    return $self;
}

sub setform {
    my $self = shift;
    my $form = shift;    
    $self->{form} = $form;
}

sub serve {
    my $self = shift;
    my $form = $self->{form};

    my $out = CGI::h1('Construction de filtre pour: ' . $form->{title});
    foreach my $sec (@{$form->{sections}}) {
	$out .= CGI::h2({-class => 'sectitle'}, $sec->{title});
	$out .= CGI::start_table();
	foreach my $q (@{$sec->{questions}}) {
	    $q->{ismultiple} = 1;
	    if (defined $q->{html_type}) {
		$q->{html_type} = 'checkbox_group';
	    }
	    $out .= $q->serve();
	}
	$out .= CGI::end_table();
    }
    return $out;
}

1;

